﻿using Microsoft.VisualStudio.Modeling;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace Project.Co_DataTransformationPrototype
{

    public static partial class Operators
    {
        public partial class Operator
        {
            private bool checkSplitOperator(IList<EntityShape> elementCollection)
            {
                Debug.Assert(opStore != null);

                // TODO: Implement precondition check
                return true;
            }

            private void showSplitOpForm(Entity sourceE)
            {
                UI.SplitOperationForm dlgBox = new UI.SplitOperationForm(sourceE);
                System.Windows.Forms.DialogResult dlgResult = dlgBox.ShowDialog();

                if (dlgResult == System.Windows.Forms.DialogResult.OK)
                    opStore = dlgBox.store;
            }

            public Operator SplitOperator(IList<EntityShape> elementCollection)
            {
                checkCreateOperator(elementCollection);

                if (elementCollection != null)
                {
                    // Determine source entity
                    EntityShape shape = elementCollection.OfType<EntityShape>().First();
                    Entity source = shape.ModelElement as Entity;

                    // Determine attributes and the target entity
                    showSplitOpForm(source);
                }

                return this;
            }
        }
    }
  
}
